<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>T100库存与WMS库存差异表</title>
    <link rel="stylesheet" href="/3nod_web/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="/3nod_web/css/formSelects-v4.css"/>
</head>
<body>
<div id="content">
    <h1>T100库存与WMS库存差异表</h1>
    <button class="layui-btn layui-btn layui-btn-sm" onclick="toExport();">导出</button>

    <form class="layui-form" action="">
        <div class="layui-form-item" style="margin-top: 20px">
            <div class="layui-inline">
                <label class="layui-form-label">据点</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="storerkey" id="storerkey" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">物料编码</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="sku" id="sku" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">库位编号</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="lottable01" id="lottable01" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">储位编号</label>
                <div class="layui-input-inline" style="width:168px;">
                    <input type="text" name="lottable02" id="lottable02" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class=" layui-inline">
                <label class="layui-form-label">差异数量</label>
                <div class="layui-input-inline " style="width: 300px;">
                    <select id="differ" lay-search name="differ" xm-select="select1">
                        <option value="">请选择</option>
                        <option value=">0">&gt;0</option>
                        <option value="<0">&lt;0</option>
                        <option value="=0">=0</option>
                    </select>
                </div>
            </div>
        </div>
    </form>
    <table class="layui-hide" id="demo" lay-filter="demo"></table>
</div>


<script src="/3nod_web/layui/layui.js" charset="utf-8"></script>
<script src="/3nod_web/js/jquery-1.8.3.js" charset="utf-8"></script>
<script src="/3nod_web/js/formSelects-v4.min.js" charset="utf-8"></script>
<script type="text/html" id="xuhao">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<script>

    var formSelects = layui.formSelects;
    //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;
    });
    layui.use('form', function () {
        var form = layui.form;
        form.render();
    });
    layui.use('table', function () {
        var table = layui.table;

        //方法级渲染
        table.render({
            elem: '#demo'
            , url: '/3nod_web/diff/getDiffStore/'
            , cellMinWidth: 150
            , cols: [
                [
                    {templet: '#xuhao', title: '序号', width: 65, fixed: true}
                    , {field: 'storerkey', title: '据点', sort: true, fixed: true, width: 80}
                    , {field: 'sku', title: '物料编码'}
                    , {field: 'lottable01', title: '库位编号'}
                    , {field: 'lottable02', title: '储位编号'}
                    , {field: 'tqty', title: 'T100数量'}
                    , {field: 'wmsqty', title: 'WMS库存'}
                    , {field: 'differ', title: '差异数量'}
                    , {field: 'unChecked', title: '待检数量'}
                ]
            ]
            , id: 'testReload'
            , height: 'full-190'
            , page: true
            , limits: [20, 50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000]
            , limit: 20
        });

        var $ = layui.$, active = {
            reload: function () {
                var storerkey = $('#storerkey');
                var lottable01 = $('#lottable01');
                var lottable02 = $('#lottable02');
                var sku = $('#sku');
                var differ = formSelects.value('select1', 'valStr');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        storerkey: storerkey.val(),
                        lottable01: lottable01.val(),
                        lottable02: lottable02.val(),
                        sku: sku.val(),
                        differ: differ,
                    }
                }, 'data');
            }
        };
        //按回车提交
        $(".layui-input-inline").keydown(function (e) {//当按下按键时
            if (e.which == 13) {//.which属性判断按下的是哪个键，回车键的键位序号为13
                // $('button.search123').trigger("click");//触发搜索按钮的点击事件
                active['reload'] ? active['reload'].call(this) : '';
            }
        });
    });
    //导出
    function toExport() {
        var storerkey = $('#storerkey').val();
        var lottable01 = $('#lottable01').val();
        var lottable02 = $('#lottable02').val();
        var sku = $('#sku').val();
        var differ = formSelects.value('select1', 'valStr');

        location.href = '/3nod_web/exportStoreDifference?storerkey=' + storerkey + "&lottable01=" + lottable01 + "&lottable02=" + lottable02
            + "&sku=" + sku + "&differ=" + differ;
    }
</script>

</body>
</html>